﻿$(function () {
    if(ID == ''){
        document.location = "/Shared/Error";
    }

    loadMenu();
    getEdu();
    getExp();
    getInfor();
    getCareer();
});


vm.career = ko.observableArray();
vm.edu = ko.observableArray();
vm.exp = ko.observableArray();
vm.infor = ko.observable();

function getCareer() {
   
    var career = new breeze.EntityQuery().from("CareerExpects").where("PersonalId", "==", ID);
    manager.executeQuery(career).then(function (data) {
        data.results.forEach(function (item) {
            vm.career.push(item);
            
        });
        ko.applyBindings(vm, $('#_overview')[0]);
    }).fail(function (e) {
        alert(e);
    });

}

function getEdu() {
    var edu = new breeze.EntityQuery().from("Educations").where("PersonalId", "==", ID);
    manager.executeQuery(edu).then(function (data) {
        data.results.forEach(function (item) {
            vm.edu.push(item);
        });
    }).fail(function (e) {
        alert(e);
    });

}
function getExp() {
    var exp = new breeze.EntityQuery().from("WorkExperiences").where("PersonalId", "==", ID);
    manager.executeQuery(exp).then(function (data) {
        data.results.forEach(function (item) {
            vm.exp.push(item);
        });
    }).fail(function (e) {
        alert(e);
    });

}
function getInfor() {
    var inf = new breeze.EntityQuery().from("PersonalInfors").where("UniqueId", "==", ID);
    manager.executeQuery(inf).then(function (data) {
        data.results.forEach(function (item) {
            vm.infor(item);
        });
    }).fail(function (e) {
        alert(e);
    });
}


function rowClick() {
    alert('click');
}